var path = require('path');
var src = __dirname + '/src';

var webpack = require('webpack');
var commonsPlugin = new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var htmlPlugin = new HtmlWebpackPlugin({
    template: path.join(src, "index.html"), minify: true, inject: 'body'
});

module.exports = {
    target: 'web',
    entry: {
        vendor: ["jquery", "jade/lib/runtime.js", "pathjs", "bluebird"],
        entry: path.join(src, "entry.coffee")
    },
    resolve: {
        root: [src],
        extensions: ['', '.js'],
        alias: {
            pathjs: 'pathjs-amd',
            bluebird: 'bluebird/js/browser/bluebird.js'
        }
    },
    output: {
        path: './dist',
        filename: "[name].js",
        publicPath: ""
    },
    module: {
        loaders: [
            {test: /\.css$/, loader: "style!css"},
            {test: /\.scss$/, loader: "style!css!sass"},
            {test: /\.coffee$/, loader: "coffee"},
            {test: /\.jade/, loader: "jade"},
            //{test: /\.jsx$/, exclude: /(node_modules|bower_components)/, loader: 'babel'},
            {
                test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/font-woff"
            }, {
                test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/font-woff"
            }, {
                test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=application/octet-stream"
            }, {
                test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
                loader: "file"
            }, {
                test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
                loader: "url?limit=10000&mimetype=image/svg+xml"
            }, {
                test: /\.(png|jpg)$/, loader: 'url?limit=8192'
            }
        ]
    },
    plugins: [commonsPlugin, htmlPlugin]
};
